package com.xss.audioandvideo;

import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import java.io.File;
import java.util.function.BiFunction;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 三种方式绘制图片：1.ImageView绘制；2.SurfaceView绘制；3.自定义View绘制
 */
public class MainActivity extends AppCompatActivity {
    private static final String TAG = "xss1";
    @BindView(R.id.image1)
    ImageView image1;
    @BindView(R.id.button1)
    Button button1;
    @BindView(R.id.button2)
    Button button2;
    @BindView(R.id.image3)
    CustomView image3;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);
    }

    @OnClick({R.id.button1, R.id.button2})
    public void onViewClick(View view) {
        switch (view.getId()) {
            case R.id.button1:
                Log.d(TAG, "onViewClick: 图片路径：" + (Environment.getExternalStorageDirectory().getPath() + File.separator + "likeke.jpg"));
//                Bitmap bitmap = BitmapFactory.decodeFile(
//                        Environment.getExternalStorageDirectory().getPath() + File.separator + "11.jpg");
                Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.like);
                image1.setImageBitmap(bitmap);
                break;
            case R.id.button2:
                Intent intent = new Intent(this, SurfaceActivity.class);
                startActivity(intent);
                break;
        }
    }
}
